﻿<%@ Page Title="Home Page" Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="SignalRPushNotification._Default" %>
<!DOCTYPE html>
<html>
<head>
    <title>SignalR Simple Chat</title>
    <style type="text/css">
        .container {
            background-color: #99CCFF;
            border: thick solid #808080;
            padding: 20px;
            margin: 20px;
        }
    </style>
</head>
<body>
    <div class="container">
        <ul id="discussion">
        </ul>
    </div>
    
    <script src="Scripts/jquery-1.8.2.min.js"></script>
    <script src="Scripts/json2.min.js"></script>
    <script src="Scripts/jquery.signalR-1.1.2.js"></script>
    <script src="signalr/hubs" type="text/javascript"></script>

    <script type="text/javascript">
        $(document).ready(function () {

            var chat = $.connection.chatHub;
            chat.client.broadcast = function (data) {
                console.log(data);
                $('#discussion').append('<li>' + data + '</li>');
            };

            $.connection.hub.start();


            //var chat = $.connection.chatHub;
            //chat.client.broadcastMessage = function (name, message, machineName, instanceId) {
            //    var encodedName = $('<div />').text(name).html();
            //    var encodedMsg = $('<div />').text(message).html();
            //    $('#discussion').append('<li><strong>' + encodedName + '</strong>:&nbsp;&nbsp;' + encodedMsg + '<br /> - Machine: ' + machineName + '<br /> - Instance: ' + instanceId + '</li>');
            //};

            //$('#displayname').val(prompt('Enter your name:', ''));
            //$('#message').focus();

            //$.connection.hub.start().done(function () {
            //    $('#sendmessage').click(function () {
            //        chat.server.send($('#displayname').val(), $('#message').val());
            //        $('#message').val('').focus();
            //    });
            //});
        });
    </script>
</body>
</html>